package com.huya.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.huya.common.result.PageResult;
import com.huya.common.result.Result;
import com.huya.mapper.TeacherMapper;
import com.huya.pojo.dto.TeacherPageQueryDTO;
import com.huya.pojo.entity.Teacher;
import com.huya.service.TeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class TeacherServiceImpl  implements TeacherService {

    @Autowired
    private TeacherMapper teacherMapper;
    /**
     * 分页查询老师列表
     * @param teacherPageQueryDTO
     * @return
     */
    public PageResult pageQuery(TeacherPageQueryDTO teacherPageQueryDTO) {
        PageHelper.startPage(teacherPageQueryDTO.getPage(), teacherPageQueryDTO.getPageSize());
        Page<Teacher> page = teacherMapper.pageQuery(teacherPageQueryDTO);
        return new PageResult(page.getTotal(), page.getResult());
    }
}
